﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:mt="clr-namespace:DeepEarth.Toolkit.Controls"
    xmlns:measure="clr-namespace:DeepEarth.Toolkit.Controls.Measure"
    >

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/DeepEarth.Toolkit.Common;component/Resources/CommonStyles.xaml"></ResourceDictionary>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="mt:MeasureTool">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="mt:MeasureTool">
                    <Grid x:Name="LayoutRoot" Opacity="0.82">

                        <Grid.Resources>
                            <measure:DistanceFormatConverter x:Key="formatter"></measure:DistanceFormatConverter>
                            <measure:AreaFormatConverter x:Key="areaFormatter"></measure:AreaFormatConverter>
                        </Grid.Resources>

                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualStateGroup.Transitions>
                                    <vsm:VisualTransition GeneratedDuration="00:00:00.3000000"/>
                                </vsm:VisualStateGroup.Transitions>
                                <vsm:VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Normal">
                                    <Storyboard/>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="OperationStates">
                                <vsm:VisualStateGroup.Transitions>
                                    <vsm:VisualTransition GeneratedDuration="00:00:00.3000000"/>
                                </vsm:VisualStateGroup.Transitions>
                                <vsm:VisualState x:Name="Open">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="lengthbox" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="area" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Closed">
                                    <Storyboard/>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>

                            <vsm:VisualStateGroup x:Name="ToggleButtonStates">
                                <vsm:VisualState x:Name="Visible">
                                    <Storyboard>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Hidden">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PART_ToggleButton" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                        
                        <StackPanel Orientation="Vertical" VerticalAlignment="Top">
                            <ToggleButton x:Name="PART_ToggleButton" ToolTipService.ToolTip="Toggle Measure Tool" IsChecked="false" HorizontalAlignment="Left" Height="25" Width="25" Style="{StaticResource ToggleButtonStyle}" Command="{Binding RulerToggleCommand, RelativeSource={RelativeSource TemplatedParent}}">
                                <Image Source="/DeepEarth.Toolkit.Controls.MeasureTool;component/Images/Ruler.png" Stretch="Uniform"/>
                            </ToggleButton>
                            <TextBox x:Name="lengthbox" 
                                               Text="{Binding Model.Distance.Description, RelativeSource={RelativeSource TemplatedParent}}" 
                                               HorizontalAlignment="Right"
                                               TextAlignment="Right" 
                                               Style="{StaticResource NoTextBoxStyle}" 
                                               IsReadOnly="True"
                                               Margin="7,0,7,0"
                                               Foreground="{TemplateBinding Foreground}"
                                               FontSize="{TemplateBinding FontSize}" />

                            <TextBox x:Name="area" 
                                               Text="{Binding Model.Area.Description, RelativeSource={RelativeSource TemplatedParent}}" 
                                               HorizontalAlignment="Right"
                                               TextAlignment="Right" 
                                               Style="{StaticResource NoTextBoxStyle}" 
                                               IsReadOnly="True"
                                               Margin="7,0,7,0"
                                               Foreground="{TemplateBinding Foreground}"
                                               FontSize="{TemplateBinding FontSize}" />
                        </StackPanel>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

